package cn.edu.niit.alienlab.jshttplessonserver.apis;

import cn.edu.niit.alienlab.jshttplessonserver.dto.MovieInfo;
import cn.edu.niit.alienlab.jshttplessonserver.dto.WeiboItem;
import cn.edu.niit.alienlab.jshttplessonserver.service.Lesson1Service;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
@CrossOrigin(origins = "*")
public class Lesson1Resource {
    private final Lesson1Service lesson1Service;

    public Lesson1Resource(Lesson1Service lesson1Service) {
        this.lesson1Service = lesson1Service;
    }

    /**
     * API1:获取动态列表
     * @return List<WeiboItem>
     */
    @GetMapping("/weibo/list")
    public ResponseEntity getWeiboList(){
        List<WeiboItem> result=this.lesson1Service.getWeiboList();
        return ResponseEntity.ok(result);
    }
    /**
     * API2:获取点赞的动态列表
     * @return List<WeiboItem>
     */
    @GetMapping("/praised/list")
    public ResponseEntity getPraiseWeibo(){
        List<WeiboItem> result=this.lesson1Service.getPraiseList();
        return ResponseEntity.ok(result);
    }
    /**
     * API3:获取收藏的影片列表
     * @return List<MovieInfo>
     */
    @GetMapping("/favorite/list")
    public ResponseEntity getFavoriteMovie(){
        List<MovieInfo> result=this.lesson1Service.getFavoriteList();
        return ResponseEntity.ok(result);
    }

}
